--浮光
local fuguang = fk.CreateSkill {
    name = "mcdh_fuguang",
    tags = {Skill.Hidden }
}

local U = require "packages/utility/utility"
local lib = require "packages/mcdh/lib"

fuguang:addEffect(U.GeneralAppeared,{
    can_trigger = function(self, event, target, player, data)
        local room = player.room
        if player == target then
            return player:hasSkill(self)
        end
    end,
    on_cost = Util.TrueFunc,
    on_use = function (self, event, target, player, data)
        local room = player.room
        player:drawCards(2,self.name)
        if player.phase == Player.NotActive then
            room:setPlayerMark(player, "@@mcdh_fuguang", room.current.id)
            U.gainAnExtraTurn(player,true,self.name)
        end
    end,
})

fuguang:addEffect(fk.TurnStart,{
    refresh_events = {fk.TurnStart},
    can_refresh = function(self, event, target, player, data)
        return target:getMark("@@mcdh_fuguang") ~= 0 and target == player
    end,
    on_refresh = function(self, event, target, player, data)
        local room = player.room
        local to = target:getMark("@@mcdh_fuguang")
        room:setPlayerMark(target, "@@mcdh_fuguang", 0)
        room:setPlayerMark(target, "#mcdh_fuguang-turn", to)
    end,
})

fuguang:addEffect('distance',{
    correct_func = function(self, from, to) return 0 end,
    fixed_func = function(self, from, to)
        local mark = from:getMark("#mcdh_fuguang-turn")
        if mark == to.id then
            return 1
        end
    end,
})

Fk:loadTranslationTable {
    ["mcdh_fuguang"] = "浮光",
    ["@@mcdh_fuguang"] = "浮光",
    [":mcdh_fuguang"] = "隐匿技,当你登场后,你摸两张牌;若你于其他角色的回合内登场,则本回合结束后你执行一个额外的回合，此额外回合内你计算与其的距离视为1。"
}

return fuguang